package com.azzcs.juc;

import java.util.concurrent.TimeUnit;

/**
 * @Author: wzg
 * @Date: 2021/7/7 上午7:02
 */
public class Deadlock {
    public static void main(String[] args) {
        Object lockA = new Object();
        Object lockB = new Object();
        new Thread(()->{
            synchronized (lockA){
                try {
                    TimeUnit.SECONDS.sleep(2);
                    synchronized (lockB){

                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
        new Thread(()->{
            synchronized (lockB){
                try {
                    TimeUnit.SECONDS.sleep(2);
                    synchronized (lockA){

                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();

    }
}
